﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using MyWeb.Extensions.ServiceExtensions.Swagger;
using MyWeb.Model.User;
using MyWeb.Repository.UnitOfWorks;
using SqlSugar;
using static MyWeb.Extensions.ServiceExtensions.Swagger.CustomApiVersion;

namespace MyWeb.Api.Controllers.V1
{
    /// <summary>
    /// 测试控制器 V1版本
    /// </summary>
    [ApiController]
    //[Route("/api/v1/[controller]/[action]")]
    [CustomRoute(ApiVersions.V1)]
    //[ApiExplorerSettings(GroupName = "V1")]
    [AllowAnonymous]
    public class TestController : ControllerBase
    {
        private readonly SqlSugarScope _dbBase;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="unitOfWorkManage"></param>
        public TestController(IUnitOfWorkManage unitOfWorkManage)
        {
            _dbBase = unitOfWorkManage.GetDbClient();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        //封装自定义路由
        public ActionResult V1_Get1()
        {
            return Ok();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult V1_Get2()
        {
            return Ok();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Get()
        {
            return new JsonResult(_dbBase.Queryable<SysUserInfo>().ToPageList(1,10));
        }
    }
}
